import 'package:dio/dio.dart';
import 'package:get/get.dart';
import 'package:getx_app/app/modules/home/models/user_info.dart';

import 'state.dart';

class ProfileLogic extends GetxController {
  final ProfileState state = ProfileState();

  final dio = Get.find<Dio>();

  @override
  void onInit() {
    getUserInfo();
    super.onInit();
  }

  Future<void> getUserInfo() async {
    state.isLoading = true;
    final res = await dio.get("/h5/learner/info");
    final data = UserInfo.fromJson(res.data["data"]);
    state.userInfo = data;
    state.isLoading = false;
    update();
  }
}
